<?php
/**
 * 卡密提取界面
 */
if (!defined('IN_CRONLITE')) die();
if (isset($_QET['pass'])) {
    $re = $DB->query("SELECT * FROM `sky_token` WHERE `code` = '{$_QET['pass']}' ORDER BY `kid` DESC ");
    $data = [];
    while ($res = $DB->fetch($re)) {
        $data[] = $res;
    }
    if ($data == []) show_msg('温馨提示', '没有查询到相关卡密,请核对提卡密码后再查询！', 3);
}
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<?php echo $cdnserver; ?>assets/layui/css/layui.css" media="all">
    <title><?= $conf['sitename'] . ($conf['title'] == '' ? '' : ' - ' . $conf['title']) ?></title>
</head>
<style>
    .images {
        width: 110%;
        height: 110%;
        background-size: 100% 100%;
        z-index: -100;
        position: fixed;
        left: -5%;
        top: -5%;
        <?= background::image() == false ? 'background:#eee;' : background::image() ?>

    }
</style
<body>
<div class="images"></div>
<div style="height: 1em" class="layui-hide-xs"></div>
<div class="layui-fluid" style="padding: 0">
    <div class="layui-row layui-col-space8">
        <div class="layui-col-xs12 layui-col-sm8 layui-col-sm-offset2">
            <div class="layui-card">
                <div class="layui-card-header"
                     style="text-align: center;font-size: 1.4em;box-shadow: 3px 3px 16px #eee">
                    <?= $conf['sitename'] ?> - 提卡中心
                    <a href="<?= (empty($_QET['pass']) ? './?mod=query' : './?mod=extract') ?>"
                       class="layui-icon layui-icon-left" style="position:absolute;left: 1rem"></a>
                </div>
                <div class="layui-card-body">
                    <?php
                    if (!isset($_QET['pass'])) {
                        ?>
                        <form class="layui-form" action="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">提卡密码</label>
                                <input type="hidden" name="mod" value="extract"/>
                                <div class="layui-input-block">
                                    <input type="text" name="pass" required lay-verify="required" placeholder="请输入提卡密码"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn layui-bg-red" lay-submit lay-filter="formDemo">确认密码
                                    </button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </div>
                        </form>
                    <?php } else {
                        ?>
                        <div style="overflow:hidden;overflow-x:auto ">
                            <table class="layui-table" lay-skin="row" lay-size="sm" style="white-space:nowrap">
                                <thead>
                                <tr>
                                    <th>KID</th>
                                    <th>商品名称</th>
                                    <th>卡密内容</th>
                                    <th>订单号</th>
                                    <th>购买时间</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php foreach ($data as $v) {
                                    $gid_data = $DB->get_row("SELECT name FROM `sky_goods` WHERE gid = '{$v['gid']}' "); ?>
                                    <tr>
                                        <td><span class="layui-badge layui-bg-gray"><?= $v['kid'] ?></span></td>
                                        <td><?= $gid_data['name'] ?></td>
                                        <td><?= $v['token'] ?></td>
                                        <td><?= $v['order'] ?></td>
                                        <td><?= $v['endtime'] ?></td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                    <?php } ?>
                    <fieldset class="layui-elem-field" style="margin-top: 1em">
                        <legend>相关说明</legend>
                        <div class="layui-field-box">
                            您购买的卡密可在此处显示出来,请输入提卡密码提取您的卡密哦~<br>
                            卡密不会永久保存,请尽快提取，此处卡密随时可能清空！
                        </div>
                    </fieldset>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

